{extend name="common/dialog" /}
{block name="main"}
<div class="layui-form-box dialog-form-box" style="margin-top:25px;">
<form class="layui-form ">
		<input type="hidden" name="pid" value="{$pid}">
		<input type="hidden" name="id" value="{$row['id']}">
        <div class="layui-form-item">
            <label class="layui-form-label" >{:lang('Name')}</label>
            <div class="layui-input-6">
                <input type="text" name="name"  value="{$row['name']}" lay-verify="required" placeholder="{:lang('Please enter the name of the cloud')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" >{:lang('English Name')}</label>
            <div class="layui-input-6">
                <input type="text" name="name_en"  value="{$row['name_en']}" lay-verify="required" placeholder="{:lang('Enter English Name')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" >{:lang('Incon')}</label>
            <div class="layui-input-6" style="position: relative;">
                <input type="text"  name="icon" placeholder="" value="{$row['icon']}" style=""  id="_icon" class="layui-input" readonly="" >
                <button type="button" class="layui-btn layui-btn-primary input-upload-btn" id="_mediaBtn" title="{:lang('Upload Image')}"><i class="icon icon-upload3"></i></button>
            </div>
            
        </div>
        <br/>
        <br/>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-label-no" ></label>
            <div class="layui-input-6 pleft22">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit" >{:lang('Submit')}</button>
            </div>
        </div>
       
    </form>
</div>
{/block}
{block name="footer"}
<script>
layui.use(['form', 'layer','upload'], function () {
    var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
    form.on('submit(submit)', function (data) {
        loading = layer.load(1,{shade:[0.1,'#fff']});
        $.post("", data.field, function (res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                    top.location.reload();
                });
            } else {
                layer.msg(res.msg, {time: 1800, icon: 2});
            }
        });
    })
     //普通图片上传
    var loading = null;
    var uploadInst = upload.render({
        elem: '#_mediaBtn'
        ,url: '{:url("api/upload/expand",array('network_id'=>$row['id']))}'
        ,data:{network_id:1}
        ,before: function(obj){
            //预读本地文件示例，不支持ie8
            loading =layer.load(1, {shade: [0.1,'#fff']});
        }
        ,done: function(res){
            layer.close(loading);  
            //上传成功
            if(res.code == 0){
                $('#_icon').val(res.url);
            }else{
                //如果上传失败
                return layer.msg("{:lang('Upload failure')}");
            }
        }
        ,error: function(){
            layer.close(loading);  
            //演示失败状态，并实现重传
            return layer.msg("{:lang('Upload failure')}");
        }
    });
});
</script>
{/block}